package cn.bob.basic.config;

import cn.bob.basic.interceptor.LoginInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author bob
 * @data 2022/10/21-16:49
 */
@Configuration
public class LoginConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //拦截所有请求
        //放行登录，注册，驻入，图片，验证码
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/login/**")
                .excludePathPatterns("/verifyCode/**")
                .excludePathPatterns("/register/**")
                .excludePathPatterns("/shop/settlement/**")
                .excludePathPatterns("/shop/pass/**")
                .excludePathPatterns("/shop/**")
                .excludePathPatterns("/menu/**")
                .excludePathPatterns("/fastdfs/**");

    }
}
